//
//  amziViewController.m
//  KidsSound
//
//  Created by Saurabh on 5/29/13.
//  Copyright (c) 2013 Amazination Technology. All rights reserved.
//

#import "amziViewController.h"

@interface amziViewController ()

@end

@implementation amziViewController

@synthesize girlURLRef,babyURLRef,momURLRef,laughlURLRef,ggURLRef,girlFileObj,
babyFileObj,momFileObj,laughFileObj,ggFileObj;

-(IBAction)girlSound:(id)sender{
    AudioServicesPlaySystemSound(self.girlFileObj);
}

-(IBAction)babySound:(id)sender{
    AudioServicesPlaySystemSound(self.babyFileObj);
}


-(IBAction)momSound:(id)sender{
    AudioServicesPlaySystemSound(self.momFileObj);
}

-(IBAction)laughSound:(id)sender{
    AudioServicesPlaySystemSound(self.laughFileObj);
}

-(IBAction)ggSound:(id)sender{
    AudioServicesPlaySystemSound(self.ggFileObj);
}


- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    //get the main budle for app to store all sounds
    
    CFBundleRef mainBundle;
    mainBundle = CFBundleGetMainBundle();
    
    //get the URL for the sound file to be played
    
    girlURLRef = CFBundleCopyResourceURL(mainBundle, CFSTR("Baby_Girl_Speaking"),CFSTR("wav"),NULL );
    
    
    babyURLRef = CFBundleCopyResourceURL(mainBundle, CFSTR("Baby_Talk"),CFSTR("wav"),NULL );
    
    momURLRef = CFBundleCopyResourceURL(mainBundle, CFSTR("Baby_Talk2"),CFSTR("wav"),NULL );
    
    laughURLRef = CFBundleCopyResourceURL(mainBundle, CFSTR("Funny_Boy_Laugh2"),CFSTR("wav"),NULL );
    
    ggURLRef = CFBundleCopyResourceURL(mainBundle, CFSTR("Giggles"),CFSTR("wav"),NULL );
    
    //Create a system sound file for each sound file
    
     AudioServicesCreateSystemSoundID(girlURLRef, &girlFileObj);
    
     AudioServicesCreateSystemSoundID(babyURLRef, &babyFileObj);
    
     AudioServicesCreateSystemSoundID(momURLRef, &momFileObj);
    
     AudioServicesCreateSystemSoundID(laughURLRef, &laughFileObj);
    
     AudioServicesCreateSystemSoundID(ggURLRef, &ggFileObj);
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void) dealloc{
    
    AudioServicesDisposeSystemSoundID(self.girlFileObj);
    AudioServicesDisposeSystemSoundID(self.babyFileObj);
    AudioServicesDisposeSystemSoundID(self.momFileObj);
    AudioServicesDisposeSystemSoundID(self.laughFileObj);
    AudioServicesDisposeSystemSoundID(self.ggFileObj);
    
    CFRelease(girlURLRef);
    CFRelease(babyURLRef);
    CFRelease(momURLRef);
    CFRelease(laughURLRef);
    CFRelease(ggURLRef);
    
    
}

@end
